#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTcpServer>
#include <QTcpSocket>
#include <QTimer>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QNetworkAccessManager>
//#include <QNetworkRequest>
//#include <QNetworkReply>
#include <QNetworkInterface>
#include <QNetworkRequest>


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();


private slots:

    bool get_db_connect();

    void on_pbSend_clicked();
    void on_pbReceive_clicked();
    void on_pbStop_clicked();
    //void newConnect();
    //void readMessage();
    void onTimeOut();

    bool manipulate_query(QJsonObject,int);
    QJsonArray query_ZHYY660(QString str_idenno,int);
    bool send_message(QJsonArray value, int channel);
    void on_pushButton_clicked();

    void on_pb_send_http_clicked();
private:
    Ui::MainWindow *ui;

    QTcpServer *tcpServer;
    QTcpSocket *tcpSocket[10];
    //QSqlQuery *tqrmt;
    QSqlQuery *qrm[10],*qrmt[10];  //, *qro[10] ,*qrot[10]
    //int i_sock_idle_index;

//    QSqlDatabase db_o;   // oracle
    QSqlDatabase db_m;   //mysql
    //QSqlQuery qr, qrm, qro;

    QTimer *tm;

    QString curDb, curSq, hasRet;
    bool receiveData;


    QNetworkRequest request;
    QNetworkAccessManager manager ;
    QNetworkReply * reply;

};
#endif // MAINWINDOW_H
